<!DOCTYPE HTML><html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title><? echo $title ?></title>
    <? require("lib.php"); ?>
</head>
<body>
<div class="content-box">
<div class="content-box-header">
    <h3><? echo $title ?></h3>
    <div class="clear"></div>
</div>
<div class="content-box-content">
    <?
    switch ($do) {
        case "add": add(); break;
        case "update": update($info); break;
        case "delete": delete($id); break;
        default:	show_info($info);
    }
    function show_box($row, $iseditmode, $isadd){
        global $id, $userid, $gee, $baseurl, $h, $refund_reason, $cate, $cateid, $customer, $product, $lang, $code_array,$payment_method, $shipment_method, $arrcurrency, $filter, $baseurl,$express_company, $coupon, $recode, $template;
        $detail_info = product_detail($row['sales_detail_id']);
        $title=$detail_info['sales_order_id'].' - '.ROOT_ORDER_DETAIL;
        // 0 未支付 / 1 已支付 / 2.处理中 / 3 寄送中 / 4 已收到  / 8 客户自己取消  / 9 经销商取消
        $refund_status=$code_array['refund_status'];
        $contact_type = $code_array['contact_type'];

        if($row['refund_reason_id'] == 0){
            $reason = $row['customer_remark'];
        }else{
            $reason_arr = $refund_reason->get_row($row['refund_reason_id'], 'id');
            $reason = $reason_arr['name_'.$lang];
        }
//            $reason = $refund_reason->get_rows(64, 'type', 2);
        $refund_code_status = $code_array['service_status'];
            $cstatus=$refund_code_status[$row['service_status']]['name_'.$lang];
        $customer_id=$row['customer_id'];
        if($customer_id==0) {
            $customer_name=ROOT_GUEST_ACCOUNT;
            $customer_account = '';
        }
        else {
            $customer_array=$customer->get_row($customer_id);
            $customer_name=$customer_array['first_name'].$customer_array['last_name'];
            $customer_account = $customer_array['email'];
            if($customer_name=='')$customer_name=$customer_array['nickname'];
        }

        $where_r = array();
        $where_r[] = array('name'=>'template_id', 'val'=>2, 'opn'=>'=', 'and'=>'and');
        $where_r[] = array('name'=>'recode_name', 'val'=>'sales_order_id', 'opn'=>'=', 'and'=>'and');
        $where_r[] = array('name'=>'recode_value', 'val'=>$detail_info['sales_order_id'], 'opn'=>'=', 'and'=>'and');
        $recode_info = $recode->get_rows_advanced(1,$where_r);
        $recode_value = explode('|', $recode_info[0]['value']);

        //$country_name=$country->get_name($row['country'],$lang);

        // 支付方式 payment_method

        echo $h->hidden('userid', $userid);
        echo $h->hidden('id', $row["id"]);
        echo $h->hidden('sales_order_id', $detail_info["sales_order_id"]);
        echo $h->hidden('filter', $filter);
        echo $h->hidden('customer_id', $customer_id);
        echo $h->hidden('refund_reason', $code_array['service_type'][$row['service_type']]['name_'.$lang]);
        ?>
        <table width="99%" cellspacing="0" cellpadding="3" class="mbox">
            <tr class="th"><td class="thtitle" width="25%" align="right"><? echo $title ?></td><td><strong><?=ROOT_ORDER_SERVICE_CATETYPE?>：<?=$code_array['service_type'][$row['service_type']]['name_'.$lang]?></strong></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_SERVICE_CATETYPE?></td><td><? echo $code_array['service_type'][$row['service_type']]['name_'.$lang] ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_ADD_SALES_ORDER?></td><td><? echo $detail_info['sales_order_id'] ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_ADD_SALES_NAME?></td><td><? echo $detail_info['product_name'] ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_SERVICE_QUANTITY?></td><td><? echo $row['quantity'] ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_SERVICE_ACCOUNT?></td><td><? echo $customer_name ?></td></tr>
            <tr><td class="l"><?=ROOT_CUSTOMER_NAME?></td><td><? echo $customer_account ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_ADD_SALES_PERSON?></td><td><? echo $row['contact_name'] ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_ADD_SALES_PHONE?></td><td><? echo $row['phone'] ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_ADD_SALES_OTHER?></td><td><? echo $contact_type[$row['contact_type']]['name_'.$lang].':&nbsp;'.$row['contact_other'] ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_ADD_SALES_REASON?></td><td><? echo d($reason); ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_ADD_SALES_DESCRIPTION?></td><td><? echo $row['description']; ?></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_ADD_CREATE_TIME?></td><td><? echo $row['create_time'] ?></td></tr>
            <? $hide=' class="hide" '; if(!empty($row['pic'])) $hide=''; ?>
            <tr <?=$hide?>><td class="l"><?=ROOT_ORDER_ADD_PIC?></td><td><a href="../upload/<?=$row['pic']?>" target="_blank"><img src="../upload/<?=$row['pic']?>" height="80" /></a></td></tr>
            <tr><td class="l"><?=ROOT_ORDER_CHECK_STATUS?></td><td><? echo $h->select('refund_status', $row["refund_status"], $refund_code_status, 'id', 'name_'.$lang, 'g') ?></td></tr>
            <tr><td class="l"><?=ROOT_HANDLING_REMARKS?></td><td><? echo $h->text('operator_remark', $row["operator_remark"], 'g'); ?></td></tr>
            <tr class="refund_account hide"><td class="l"><?=ROOT_ORDER_SERVICE_REFUND_ACCOUNT?></td><td><? echo $h->text('refund_account', $customer_account, 'g'); ?></td></tr>
            <tr class="refund_amount hide"><td class="l"><?=ROOT_ORDER_SERVICE_REFUND_SUM?></td><td><? echo $h->text('refund_amount', $recode_value[3], 'g'); ?></td></tr>
            <tr><td class="l">&nbsp;</td><td><br><? echo $h->submit('save', '&nbsp; '.ROOT_HANDLE_ORDER.' &nbsp;', $iseditmode==1?' button':'hide') ?>&nbsp; <a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br>
                </td></tr>
        </table>
    <? } ?>
    <? function show_boxes($result){
        global $page, $pages, $baseurl, $cate, $cateid, $s, $gee, $url, $product, $user, $lang, $country, $code_array, $arrcurrency, $customer, $filter, $h,$payment_method;
        // 构造收款方式数组 arr_payment
        $str='<table width="99%" class="mlist"><tr>';  // 搜索
        $str.='<td><form action="'.$url.'.php" method="get"><input placeholder="'.ROOT_SEARCH_BY_ORDER_REFERENCE_CUSTOMER_MOBILE.'" name="s" class="g" value="'.$s.'" /> &nbsp; <input class="button_blue" type="submit" value=" '.ROOT_SEARCH.' " /></form></td>';
        $str.='<td '.(($s!='')?"class=\"nada\"":"").' align="right"><form action="'.$url.'.php" method="get">'.$h->select('filter', $filter, $code_array['service_status'], 'id', 'name_'.$lang, 'g', 'this.form.submit()').'</form></td>';
        $str.='</tr></table>';
        $str.= '<table width="99%" cellspacing="0" cellpadding="3" class="mlist" id="picbox"><tr class="th"><td><strong>#</strong></td><td><strong>'.ROOT_ORDER_ADD_SALES_ORDER.'</strong></td><td><strong>'.ROOT_ORDER_ADD_SALES_NAME.'</strong></td><td><strong>'.ROOT_ORDER_ADD_SALES_PERSON.'</strong></td><td><strong>'.ROOT_ORDER_ADD_SALES_PHONE.'</strong></td><td>'.ROOT_ORDER_SERVICE_CATETYPE.'</td><td><strong>'.ROOT_SERVICE_CHECK_STATUS.'</strong></td><td><strong>'.ROOT_ORDER_ADD_CREATE_TIME.'</strong></td><td><strong>'.ROOT_ORDER_ADD_UPDATE_TIME.'</strong></td>
		<td><a class="nada" href="'.$url.'.php?a=add">[ '.ROOT_ADD.' ]</a></td></tr>';
        $status=$code_array['order_status'];
        $refund_code_status = $code_array['refund_status'];
        //print_r($refund_code_status);
        $count=1;
        foreach($result as $row)
        {
            //print_r($row);
            $iteming='';
                $cstatus=$refund_code_status[$row['refund_status']]['name_'.$lang];
            //$bstatus = $status[$row['order_status']]['name_'.$lang];
            $customer_id=$row['customer_id'];
            if($customer_id==0) $customer_name=ROOT_GUEST_ACCOUNT;
            else {
                $customer_array=$customer->get_row($customer_id);
                $customer_name=$customer_array['email'];
            }
            $detail_info = product_detail($row['sales_detail_id']);

            $id=$row['id'];
            $str.='<tr><td>'.$id.'.</td><td><a href="'.$url.'.php?do=update&id='.$id.(($filter=="")?"":"&filter=".$filter).'">'.decode($detail_info['sales_order_id']).'</a></td><td>'.decode($detail_info['product_name']).'</td><td>';
            $str.=$row['contact_name'].'</td><td>'.$row['phone'].'</td><td>'.$code_array['service_type'][$row['service_type']]['name_'.$lang].'</td><td>'.$cstatus.'</td><td>'.$row['create_time'].'</td><td>'.$row['update_time'].'</td><td><a href="'.$url.'.php?do=update&id='.$id.(($filter=="")?"":"&filter=".$filter).'">'.ROOT_HANDLE.'</a></td></tr>';
            $count++;
        }
        $str.= "</table>";
        if($count==1) $str.= "<br>".ROOT_NO_DATA."!";
        echo $str;
        echo echo_page_raw($page, $pages, $url.'.php?filter='.$filter.'&page=');
    } ?>
    <br class="clear" />
</div>
<br class="clear" />
</div>
<script type="text/javascript">
    $(function(){
        $('select[name="refund_status"]').on('change',function(){
            if($(this).val() == 4){
                $('.refund_account').removeClass('hide');
                $('.refund_amount').removeClass('hide');
            }else{
                $('.refund_account').addClass('hide');
                $('.refund_amount').addClass('hide');
            }
        });
        $('select[name="refund_status"]').triggerHandler('change');
        if($('select[name="refund_status"]').val()==4){
//            $('select[name="refund_status"]').attr('disabled', true);
        }
    });
</script>
</body>
</html>
